<%--
  Created by IntelliJ IDEA.
  User: hkw14
  Date: 2021/5/9
  Time: 11:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加商品</title>
    <link rel="stylesheet" href="${ctx}/resource/layui/css/layui.css">

</head>
<body>
<form class="layui-form" action="" onsubmit="return false">
    <div class="layui-form-item">
        <label class="layui-form-label">商品类别</label>
        <div class="layui-input-inline">
            <input type="text" name="goodsType" required  lay-verify="required" placeholder="商品类别" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">品牌</label>
        <div class="layui-input-inline">
            <input type="text" name="brand" required  lay-verify="required" placeholder="品牌" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-inline">
            <input type="text" name="goodsName" required  lay-verify="required" placeholder="商品名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">供应商</label>
        <div class="layui-input-inline">
            <input type="text" name="providerName" required  lay-verify="required" placeholder="供应商" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">商品简介</label>
        <div class="layui-input-inline">
            <textarea name="description" placeholder="商品简介" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formsub">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
    <script src="${ctx}/resource/layui/layui.js"></script>
    <script type="text/javascript">
        layui.use(['form','jquery'], function() {
            var form = layui.form;
            var $ = layui.jquery;

            form.on('submit(formsub)', function(data){
                var param = data.field;
                $.post("good.do?type=addNewGoods",param,function (res) {
                    if (res.code == 200){
                        alert("商品添加成功");
                    }else {
                        alert("商品添加失败");
                    }
                });
                return false;
            });
        })
    </script>
</form>
</body>
</html>
